<?php

$steps = array(

	// Step 1
	array(
		// Step name
		'name' => 'Select your language',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'To begin, please select the preferred language and click on "Next".',
			),

			// Language selection drop down box
			// PHP Setup wizard will automatically scan for available languages and display them
			array(
				'type' => 'language',
				'label' => 'Language',
				'name' => 'language',
			),
		),
	),

	// Step 3
	array(
		// Step name
		'name' => 'Server requirements',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'Before proceeding with the full installation, we will carry out some tests on your server configuration to ensure that you are able to install and run our software.
				Please ensure you read through the results thoroughly and do not proceed until all the required tests are passed.',
			),

			// Check PHP configuration
			array(
				'type' => 'php-config',
				'label' => 'Required PHP settings',
				'items' => array(
					'php_version' => array('>=4.0', 'PHP Version'), // PHP version must be at least 4.0
					'safe_mode' => false, // "safe_mode" must be disabled
					'upload_max_filesize' => '>=2mb', // "upload_max_filesize" must be at least 2mb
				),
			),

			// Check loaded PHP modules
			array(
				'type' => 'php-modules',
				'label' => 'Required PHP modules',
				'items' => array(
					'mysql' => array(true, 'MySQL'), // make sure "mysql" module is loaded
				),
			),

			// Verify folder/file permissions
			array(
				'type' => 'file-permissions',
				'label' => 'Folders and files',
				'items' => array(
					'../gfx/' => 'write', // make sure "cache" folder is writable
					'../secure/connect.php' => 'write', // make sure "config.php" file is writable
				),
			),
		),
	),

	// Step 5
	array(
		// Step name
		'name' => 'Database settings',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'Specify your database settings here. Please note that the database for our software must be created prior to this step. If you have not created one yet, do so now.',
			),

			// Text box
			array(
				'label' => 'Database hostname',
				'name' => 'db_hostname',
				'type' => 'text',
				'default' => 'localhost',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Database username',
				'name' => 'db_username',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Database password',
				'name' => 'db_password',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Database name',
				'name' => 'db_name',
				'type' => 'text',
				'default' => '',
				'highlight_on_error' => false,
				'validate' => array(
					array('rule' => 'required'), // make it "required"
					array(
						'rule' => 'database', // system will automatically verify database connection details based on the provided values
						'params' => array(
							'db_host' => 'db_hostname',
							'db_user' => 'db_username',
							'db_pass' => 'db_password',
							'db_name' => 'db_name'
						)
					),
				),
			),
		),
	),

	// Step 6
	array(
		// Step name
		'name' => 'Ready to install',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'We are now ready to proceed with installation. At this step we will attempt to create all required tables and populate them with data. Should something go wrong, go back to the Database Settings step and make sure everything is correct.',
			),
		),

		// Callback functions that will be executed
		'callbacks' => array(
			array('name' => 'install'), // run "install" function the "includes/callbacks.php" file upon successful form submission
		),
	),

	// Step 7
	array(
		// Step name
		'name' => 'Administrator account',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'Database tables have been successfully created and populated with data!',
			),
			array(
				'type' => 'info',
				'value' => 'You may now set up an administrator account for yourself. This will allow you to manage the website through the control panel.',
			),

			// Text box
			array(
				'label' => 'Username',
				'name' => 'user_name',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Password',
				'name' => 'user_password',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
					array('rule' => 'alpha_numeric'), // make sure only alpha-numeric characters are provided
					array('rule' => 'min_length', 'params' => 5), // make sure password does not contain less than 5 characters
					array('rule' => 'max_length', 'params' => 20), // make sure password does not contain more than 20 characters
				),
			),

			// Text box
			array(
				'label' => 'Email',
				'name' => 'user_email',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"					
					array('rule' => 'valid_email'), // make sure email address is valid
				),
			),
		),

		// Callback functions that will be executed
		'callbacks' => array(
			array('name' => 'setup_admin'), // run "setup_admin" function the "includes/callbacks.php" file upon successful form submission
		),
	),
	
	// Step 7
	array(
		// Step name
		'name' => 'Site Configuration',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'Enter the settings you wish the site to have',
			),
			array(
				'label' => 'Site Title',
				'name' => 'site_title',
				'type' => 'text',
				'default' => 'Paid4Upload.com | PPD',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
			
			array(
				'label' => 'Site Email',
				'name' => 'site_email',
				'type' => 'text',
				'default' => 'admin@paid4upload.com',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Upload Path',
				'name' => 'upload_path',
				'type' => 'text',
				'default' => rtrim(preg_replace('#/install/$#', '', BASE_PATH), '/').'/uploads/',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Site URL',
				'name' => 'site_path',
				'type' => 'text',
				'default' => rtrim(preg_replace('#/install/$#', '', VIRTUAL_PATH), '/').'/',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
			
			array(
				'label' => 'Referral Percentage',
				'name' => 'ref_percent',
				'type' => 'text',
				'default' => '0.5',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
			
			array(
				'label' => 'Affiliate Percentage',
				'name' => 'aff_percent',
				'type' => 'text',
				'default' => '0.8',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
			
			array(
				'label' => 'Payment Threshold',
				'name' => 'pay_threshold',
				'type' => 'text',
				'default' => '10',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
		),

		// Callback functions that will be executed
		'callbacks' => array(
			array('name' => 'setup_site'), // run "setup_site" function the "includes/callbacks.php" file upon successful form submission
		),
	),
	
	
	
	// Step 7
	array(
		// Step name
		'name' => 'FTP Configuration',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'You must create an FTP account before entering the settings here.',
			),
			array(
				'label' => 'Hostname',
				'name' => 'ftp_hostname',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
			
			array(
				'label' => 'Username',
				'name' => 'ftp_username',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Password',
				'name' => 'ftp_password',
				'type' => 'text',
				'default' => '',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),

			// Text box
			array(
				'label' => 'Upload Path',
				'name' => 'upload_path',
				'type' => 'text',
				'default' => rtrim(preg_replace('#/install/$#', '', BASE_PATH), '/').'/ftp/',
				'validate' => array(
					array('rule' => 'required'), // make it "required"
				),
			),
		),

		// Callback functions that will be executed
		'callbacks' => array(
			array('name' => 'setup_ftp'), // run "setup_ftp" function the "includes/callbacks.php" file upon successful form submission
		),
	),

	// Step 8
	array(
		// Step name
		'name' => 'Completed',

		// Items we're going to display
		'fields' => array(

			// Simple text
			array(
				'type' => 'info',
				'value' => 'Administrator\'s account has been successfully created.',
			),
			
			array(
				'type' => 'info',
				'value' => 'Your Administration control panel is located at:',
			),
			array(
				'type' => 'info',
				'value' => ''.rtrim(isset($_SESSION['params']['site_path']) ? $_SESSION['params']['site_path'] : '', '/').'/admin/'
			),
			array(
				'type' => 'info',
				'value' => 'You may login using these details:',
			),
			array(
				'type' => 'info',
				'value' => 'Username is '.(isset($_SESSION['params']['user_email']) ? $_SESSION['params']['user_name'] : '').'<br/>
				Password is '.(isset($_SESSION['params']['user_password']) ? $_SESSION['params']['user_password'] : ''),
			),
		),
	),
);